package outbound.wave.dataObjects
{
	import mx.collections.ArrayCollection;
	import common.utils.DateManager;
	
	public class WaveDO
	{
		public var INTERNAL_WAVE_NUM:Number = 0;
		public var WAREHOUSE:String = "";
		public var WAVE_NAME:String = "";
		public var WAVE_FLOW:String = "";
		public var CREATE_TASK:String = "";
		public var STATUS:Number = 0;
		public var CURRENT_WAVE_STEP:String = "";
		public var LAST_WAVE_STEP:String = "";
		public var WAVE_MODE:String = "";
		public var TOTAL_SHIPMENTS:Number = 0;
		public var TOTAL_LINES:Number = 0;
		public var TOTAL_QTY:Number = 0;
		public var QUANTITY_UM:String = "";
		public var WAVE_DATE_TIME_STARTED:String = "";
		public var WAVE_DATE_TIME_ENDED:String = "";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var ERROR_MESSAGE:String = "";

		public function WaveDO()
		{
		}
		
		public function Init(xmlObj:XML):void{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}			
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
			<WAVE>
				<INTERNAL_WAVE_NUM>{INTERNAL_WAVE_NUM}</INTERNAL_WAVE_NUM>
				<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
				<WAVE_NAME>{WAVE_NAME}</WAVE_NAME>
				<WAVE_FLOW>{WAVE_FLOW}</WAVE_FLOW>
				<CREATE_TASK>{CREATE_TASK}</CREATE_TASK>
				<STATUS>{STATUS}</STATUS>
				<CURRENT_WAVE_STEP>{CURRENT_WAVE_STEP}</CURRENT_WAVE_STEP>
				<LAST_WAVE_STEP>{LAST_WAVE_STEP}</LAST_WAVE_STEP>
				<WAVE_MODE>{WAVE_MODE}</WAVE_MODE>
				<TOTAL_SHIPMENTS>{TOTAL_SHIPMENTS}</TOTAL_SHIPMENTS>
				<TOTAL_LINES>{TOTAL_LINES}</TOTAL_LINES>
				<TOTAL_QTY>{TOTAL_QTY}</TOTAL_QTY>
				<QUANTITY_UM>{QUANTITY_UM}</QUANTITY_UM>
				<WAVE_DATE_TIME_STARTED>{WAVE_DATE_TIME_STARTED}</WAVE_DATE_TIME_STARTED>
				<WAVE_DATE_TIME_ENDED>{WAVE_DATE_TIME_ENDED}</WAVE_DATE_TIME_ENDED>
				<USER_STAMP>{USER_STAMP}</USER_STAMP>
				<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>			
			</WAVE>;
			return xmlObj;
		}

		public static function getWaveList(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var wavDO:WaveDO = new WaveDO();
				wavDO.Init(xml);
				ac.addItem(wavDO);
			}
			return ac;
		}
	}
}